<!--
 * @Author       : wfl
 * @LastEditors  : wfl
 * @description  :
 * @updateInfo   :
 * @Date         : 2022-11-30 14:48:25
 * @LastEditTime : 2023-04-10 18:51:40
-->
<script lang="ts" setup name="Ellipsis">
defineProps({
  row: {
    type: Number,
    default: 1
  },
  hoverTip: {
    type: Boolean,
    default: false
  },
  content: {
    type: String,
    default: ''
  }
})
</script>

<template>
  <div
    :class="{ line: row === 1, lines: row > 1 }"
    :title="hoverTip ? content : undefined"
    :style="{ '--row': row }"
  >
    <slot name="pre"></slot>
    {{ content }}
  </div>
</template>

<style lang="scss" scoped>
.line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lines {
  display: -webkit-box;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: var(--row);
  -webkit-box-orient: vertical;
}
</style>
